package org.holynite.fieldmanage.entities

import org.hibernate.annotations.GenericGenerator
import org.holynite.fieldmanage.types.Privileges

import javax.persistence.Column
import javax.persistence.Entity
import javax.persistence.EnumType
import javax.persistence.Enumerated
import javax.persistence.GeneratedValue
import javax.persistence.Id
import javax.persistence.Table

/**
 * Created by midnite on 15/1/14.
 */
@Entity
@Table(name = "role_privilege")
class RolePrivilege implements Serializable {
	@Id
	@Column(name = "srp_id")
	@GeneratedValue(generator = "srp-gen")
	@GenericGenerator(name = "srp-gen", strategy = "uuid")
	String arpid
	@Column(name = "belong_to")
	String belongsTo
	@Enumerated(value = EnumType.STRING)
	@Column(name = "privilege", nullable = false)
	Privileges privilege

	boolean equals(o) {
		if (this.is(o)) return true
		if (getClass() != o.class) return false

		RolePrivilege that = (RolePrivilege) o

		if (arpid != that.arpid) return false

		return true
	}

	int hashCode() {
		return (arpid != null ? arpid.hashCode() : 0)
	}
}
